package xyz.syyrjx.blog.entity;

/**
 * @author 大地崩坏苍蝇兽
 * @date 2023/12/27 19:44
 * @description ...
 * @since v0.0.1
 */
public class Result {
    // 0-失败，1-成功
    private Integer code;
    // 成功数据
    private Object data;
    //失败消息
    private String msg;

    private Result(){}

    public static Result success(Object data) {
        Result result = new Result();
        result.data = data;
        result.code = 1;
        return result;
    }

    public static Result fail(String msg) {
        Result result = new Result();
        result.msg = msg;
        result.code = 0;
        return result;
    }


    public static Result create(int code, Object data, String msg) {
        Result result = new Result();
        result.code = code;
        result.data = data;
        result.msg = msg;
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public Object getData() {
        return data;
    }

    public String getMsg() {
        return msg;
    }


    public static final int IMAGE_SUCCESS_CODE = 444;
}
